/*
2021-7-19
https://leetcode-cn.com/problems/maximum-number-of-words-you-can-type/
*/
bool st[27]={false};
bool flag;

class Solution {
public:
    int canBeTypedWords(string text, string brokenLetters) {
        int cnt=0;
        flag=true;
        memset(st,false,sizeof st);
        if(brokenLetters.size())
        {
            for(auto t:brokenLetters)
            {
                st[t-'a']=true;
            }
        }
        for(auto t:text)
        {
            if(t==' ')
            {
                if(flag) cnt++;
                flag=true;
            }
            else
            {
                if(st[t-'a']) flag=false;
            }
        }
        if(text[0]==' ') cnt--;
        if(flag) cnt++;
        return cnt;
    }
};
